<template>
  <div v-if="comments.length !== 0" class="comment-info">
    <div class="info-head">
      <span>用户评价</span>
      <span>更多 &gt;</span>
    </div>
    <div class="info-list">
      <div class="info-user">
        <img :src="comments[0].user.avatarUrl" alt="">
        <span>{{comments[0].user.nickname}}</span>
      </div>
      <div class="info-content">
        {{comments[0].content}}
      </div>
      <div class="info-time">
        {{commentTime}}
      </div>
    </div>
  </div>
</template>

<script>
  import {formatDate} from 'common/utils'

  export default {
    name: 'DetailCommentInfo',
    props: {
      comments: {
        type: Array,
        default() {
          return []
        }
      }
    },
    computed: {
      commentTime() {
        return formatDate(new Date(this.comments[0].time), 'yyyy-MM-dd hh:mm:ss')
      }
    }
  }
</script>

<style scoped>
  .comment-info {
    padding: 20px 10px;
    border-bottom: 5px solid #eee;
  }

  .info-head {
    display: flex;
    justify-content: space-between;
    color: #000;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
  }

  .info-user {
    margin: 10px 0;
  }

  .info-user img {
    width: 50px;
    height: 50px;
    border-radius: 50px;
    vertical-align: middle;
  }

  .info-user span {
    color: #000;
    margin: 0 10px;
  }

  .info-content {
    font-size: 13px;
    margin: 10px 5px;
  }

  .info-time {
    font-size: 11px;
    color: #999;
    margin-left: 5px;
  }
</style>